package com.infoland.afanmall.model.my.activity;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.blankj.utilcode.util.ToastUtils;
import com.bumptech.glide.Glide;
import com.infoland.afanmall.R;
import com.infoland.afanmall.base.dialog.ShareDialogFragment;
import com.infoland.afanmall.base.util.CacheKit;
import com.infoland.afanmall.base.util.GlideKit;
import com.infoland.afanmall.base.util.LogKit;
import com.infoland.afanmall.base.util.StatusBarKit;
import com.infoland.afanmall.base.util.ToolsKit;
import com.infoland.afanmall.base.util.UserKit;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class SettingActivity extends AppCompatActivity {
    @BindView(R.id.setting_qing_hc)
    LinearLayout settingQingHc;
    @BindView(R.id.setting_about)
    LinearLayout settingAbout;
    @BindView(R.id.setting_share)
    LinearLayout settingShare;
    @BindView(R.id.setting_tui_chu)
    LinearLayout settingTuiChu;
    @BindView(R.id.title_layout)
    LinearLayout titleLayout;
    @BindView(R.id.huan_cun)
    TextView huanCun;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.setting_activity);
        ButterKnife.bind(this);
        StatusBarKit.immersiveBlackTitleText(this, titleLayout);
        initData();
    }

    private void initData() {
        LogKit.E("aaaa ---->   ", "  " + GlideKit.getInstance().getCacheSize());
        huanCun.setText(GlideKit.getInstance().getCacheSize());
    }

    @OnClick({R.id.back, R.id.setting_qing_hc, R.id.setting_about, R.id.setting_share, R.id.setting_tui_chu})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            /***返回**/
            case R.id.back:
                finish();
                break;
            /***清空缓存**/
            case R.id.setting_qing_hc:
                GlideKit.getInstance().clearImageAllCache();
                huanCun.setText("0M");
                break;
            /***关于**/
            case R.id.setting_about:
                ToolsKit.go(this, AboutActivity.class);
                break;
            /***分享**/
            case R.id.setting_share:
                ShareDialogFragment openShareDialog = new ShareDialogFragment();
                openShareDialog.setShowBottom(true);
                openShareDialog.show(getSupportFragmentManager());
                break;
            /****退出登录*/
            case R.id.setting_tui_chu:
                UserKit.setUserCacheNo();
                ToastUtils.showShort("已退出");
                finish();
                break;
        }
    }

    @Override
    protected void onDestroy() {
        ToolsKit.deleteOKHttp(this);
        super.onDestroy();
    }
}
